import 'dart:convert';

class PhotoAsset {
  String identity;
  int width;
  int height;

  PhotoAsset({
    this.identity,
    this.width,
    this.height,
  });

  Map<String, dynamic> toMap() {
    return {
      'identity': identity,
      'width': width,
      'height': height,
    };
  }

  factory PhotoAsset.fromMap(Map<String, dynamic> map) {
    if (map == null) return null;

    return PhotoAsset(
      identity: map['identity'],
      width: map['width'],
      height: map['height'],
    );
  }

  String toJson() => json.encode(toMap());

  factory PhotoAsset.fromJson(String source) =>
      PhotoAsset.fromMap(json.decode(source));
}
